package com.zyp.servlet;

import com.zyp.service.TheClassDaoService;
import com.zyp.tool.Tool;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "TheClassUpdateServlet", urlPatterns = "/theClassUpdateServlet")
public class TheClassUpdateServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        //获取到从前端传过来的更新的值
        Object[] objects = Tool.GetTheClassValue(request);

        //执行sql
        TheClassDaoService theClassDaoService = new TheClassDaoService();
        theClassDaoService.getUpdateService(objects);
        //修改完成后在次跳转回来
        response.sendRedirect("http://localhost:8081/task_5module_1/theClassUpdate.jsp");
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
